<?php
class KickOutMember {
	private $message = "";
	private $auth = null;
	function KickOutMember() {
		$this->auth = new Authority(true);
	}
	public function run() {
		$p = '/@(\S+)\s+([0-9]+)/';
		preg_match($p, trim($_POST[Message]), $m);
		if ($m) {

			if (trim($m[2]) != "1" && $this->auth->isClusterAdmin > 0) {
				$qq = trim($m[2]);
				$flag = $this->kickOutM($qq);
			} else {
				$qq = $_POST[Sender];
				$flag = $this->kickOutM($qq, true);
			}
			if ($flag) {
				$this->message = "踢人成功-。-";
			}

		} else {

			$this->message = "参数错误, @T 1  踢自己  @T qq 踢掉指定人员";
		}

	}

	public function kickOutM($qq, $flag = false) {
		$api = new Api("IsClusterAdmin");
		$lv = (int) $_POST[RobotAdmin];
		if ($lv < 1) {
			if ($flag)
				$this->message = "如果索妮娅是管理员肯定会踢掉你的。。";
			else
				$this->message = "索妮娅还不是本群的管理员,当然不能踢人啦 ╮(╯▽╰)╭";
			return false;
		}

		$lv = (int) $api->doApi($_POST[ClusterNum], $qq);
		if ($lv > 0) {
			if ($flag)
				$this->message = "哼!，敢把群转给索妮娅酱，我就敢踢掉你、、";
			else
				$this->message = "管理员什么的,索妮娅也不能踢掉啦╮(╯▽╰)╭";
			return false;
		} else
			if ($lv < 0) {
				$this->message = "咦。你个baka。这人貌似不再本群╮(╯▽╰)╭";
				return false;
			}
		if($qq=="261589289") {
			$this->message = "索妮娅酱才不会踢掉我的主人呢0(>_<)0" ;
			return;
		}
		$api = new Api("KickOutMember");
		$api->doApi($_POST[ClusterNum], $qq);
		return true;

	}

	private function __get($property_name) {
		return $this-> $property_name;
	}

	private function __set($property_name, $value) {
		$this-> $property_name = $value;
	}
}
?>